package practite;

import java.util.Random;
import java.util.Scanner;

public class exercise01 {
    public static void main(String[] args) {
        //1.1手动输入一个学生的成绩,对向合格成绩进行一次加分,加当前成绩的20%,输出加分后成绩
        /*System.out.println("输入学生成绩");
        double grade = getDoubleScabber();
        if (grade<0||grade>100){
            System.out.println("不合格");
        }else {
            grade = getAddGrade(grade);
        }
        System.out.println(grade);*/
        //1.2商场举行店庆,抽几折打几折
        /*System.out.println("输入游戏金额开始抽奖");
        int price = getIntScabber();
        int discount = getrandom(10,1);
        System.out.println("您抽到了"+discount+"折,折后价格为"+price*discount*0.1);*/
        //1.3手动输入一个4位数,球各位数字之和
        System.out.println("输入数字");
        int grade = getIntScabber();
        int lo = String.valueOf(grade).length();
        int sum = 0;
        int a = 0;
        for (int i = 0; i < lo; i++) {
            sum += grade%10;
            grade/=10;
            a++;
        }
        System.out.println(sum);
        System.out.println(a);
        //2.1商场消费返利活动,手动输入顾客消费金额
        /*System.out.println("请输入消费金额");
        double price = getDoubleScabber();
        price *= 0.8;
        if (price>1000){
            System.out.println("恭喜获得200元代金券");
        }
        System.out.println("感谢消费");*/
        //2.2手动输入a,b,c变量的数值,要求通过数值交换,把输入的数值从小到大排序放入a,b,c中,并输出
        /*int a = getrandom(1000,1);
        int b = getrandom(1000,1);
        int c = getrandom(1000,1);
        int max = 0;
        while (true){
            if (a<b){
                max = b;
                b = a;
                a = max;
            }
            if (b<c){
                max = c;
                c = b;
                b = max;
            }
            if (a>b&&b>c){
                break;
            }
        }
        System.out.println(a+">"+b+">"+c);*/
        //2.3练习:声明变量保存订单的状态码,根据订单的状态码打印对应的汉字状态
        /*System.out.println("输入订单状态1-等待付款2-等待发货3-运输中 4-已签收 5-已取消  其他-无法追踪");
        int state = getIntScabber();
        getstate(state);*/
        //3.1商场根据会员积分打折
        /*System.out.println("请输入积分");
        int integral = getIntScabber();
        System.out.println("输入购物金额");
        double price = getDoubleScabber();
        double discountprice = discount(integral,price);
        System.out.println("打折后的价格为"+discountprice);*/
        //3.2机票价格按照淡季旺季、头等舱和经济舱收费、
        //选择一个形状（1长方形、2正方形、3三角形、4圆形）
        //3.4输入年份和月份，输出这个月应该有多少天（使用switch结构）

    }
    //求分数
    public static double getAddGrade(double grade){
        if (grade>=60){
            grade*=1.2;
            if (grade>100){
                grade = 100;
            }
        }
        return grade;
    }

    //输入double数据
    public static double getDoubleScabber(){
        Scanner scanner = new Scanner(System.in);
        double a = scanner.nextDouble();
        return a;
    }

    //输入int数据
    public static int getIntScabber(){
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        return a;
    }

    //随机数
    public static int getrandom(int max,int min){
        Random random = new Random();
        int a = (random.nextInt(max-min+1))+min;
        return a;
    }

    //订单状态确认
    public static void getstate(int state){
        switch (state){
            case 1:
                System.out.println("1-等待付款");
                break;
            case 2:
                System.out.println("2-等待发货");
                break;
            case 3:
                System.out.println("3-运输中  ");
                break;
            case 4:
                System.out.println("4-已签收  ");
                break;
            case 5:
                System.out.println("5-已取消  ");
                break;
            default:
                System.out.println("其他-无法追踪");
                break;
        }
    }

    //购物积分打折
    public static double discount(int integral,double price){
        if (integral<0){
            return -1;
        }else {
            if (integral<2000){
                price*=0.9;
            }else if (integral<4000){
                price*=0.8;
            }else if (integral<8000){
                price*=0.7;
            }else {
                price*=0.6;
            }
        }
        return price;
    }
}
